//#include "G8I2C.h"
//xTimerHandle xTimer;
//xQueueHandle G8I2CQueue;
//static vtI2CStruct vtI2C0;
//extern xQueueHandle GraphQueue;
//#define MsgTypeVoltage 0x1
//uint8_t SlaveAddress =  0x0A;
//
//
//struct vtI2CMsg * msg;
//portTickType xLastWakeTime;
//vtI2CStruct devPtr;
//const portTickType xFrequency = 1000/ portTICK_RATE_MS;
////uint8_t getValue(vtVoltageMsg *Buffer);
//float volts = 0.0;
//
//
//
//
//
//
//
//
//
//void G8I2CTaskCode( void * pvParameters )
//{
//	
//	int state = 0;
//	// Initialize I2C0 for I2C0 at an I2C clock speed of 100KHz
//	if (vtI2CInit(&devPtr,1,tskIDLE_PRIORITY,100000) == vtI2CInitSuccess) {
//		//VT_HANDLE_FATAL_ERROR(0);
//		state = 6;
//	}
//	//state = vtI2CInit(devPtr,0,tskIDLE_PRIORITY,100000);
//	//state = 3;
//		//VT_HANDLE_FATAL_ERROR(0);
//		// state = 1;
//		//}
////		if( GraphQueue != 0 ){
////		struct I2cPacket v;
////		v.value = 13;
////		struct I2cPacket * msg = &v;
////
////		if( xQueueSend( GraphQueue, ( void * ) &msg, 5000/portTICK_RATE_MS ) != pdPASS )
////        {
////            // Failed to post the message, even after 10 ticks.
////			
////	        }
////			}
////state = 1;
////			}
//	
////
////     struct vtVoltageMsg msgBuffer;
////	 
//	 uint8_t msgType = MsgTypeVoltage;
//	 //short int* buff[2];
//	 uint8_t status;
//	 uint8_t txLen = 2;
//	 uint8_t rxLen = 2;
//	 uint8_t buff[vtI2CMLen];
//	 uint8_t maxLen = 4;
////////   dev: pointer to the vtI2CStruct data structure
////////   msgType: The message type value -- does not get sent on the wire, but is included in the response in the message queue
////////   slvAddr: The address of the i2c slave device you are addressing
////////   txLen: The number of bytes you want to send
////////   txBuf: The buffer holding the bytes you want to send
////////   rxLen: The number of bytes that you would like to receive
//////
//	if (vtI2CEnQ(&devPtr,msgType,SlaveAddress,txLen,buff,0) == pdTRUE) {
//		//VT_HANDLE_FATAL_ERROR(0);
//		state=7;
//			}
//	
////
////	//   dev: pointer to the vtI2CStruct data structure
//////   maxRxLen: The maximum number of bytes that your receive buffer can hold
//////   rxBuf: The buffer that you are providing into which the message will be copied
//////   rxLen: The number of bytes that were actually received
//////   msgType: The message type value -- does not get sent/received on the wire, but is included in the response in the message queue
//////   status: Return code of the operation (you will need to dive into the code to understand the status values)
////// Return:
//////   Result of the call to xQueueReceive()
////
////
////
////
////
////	struct I2cPacket * voltage;
//
//	// Get the parameters
//	//vtConductorStruct *param = (vtConductorStruct *) pvParameters;
//	// Get the I2C device pointer
//	//vtI2CStruct *devPtr = param->dev;
//	// Get the LCD information pointer
//	//vtTempStruct *tempData = param->tempData;
//	struct vtVoltageMsg msgBuffer;
//	
//		 
//  for( ;; )
//  {
////		if(state==0){
////  		//if(vtI2CInit(devPtr,0,tskIDLE_PRIORITY,100000) != vtI2CInitSuccess){
////		//printf("hello world");
////		 status = 1;
////		//}
////		state = 1;
////		}
//		
////  		if (vtI2CDeQ(&devPtr,maxLen,buff,&rxLen,&msgType,&status) == pdTRUE) {
////			//VT_HANDLE_FATAL_ERROR(0);
////			state++;
////		}
// 				
//	 if( G8I2CQueue != 0 )
//    {
//        // Receive a message on the created queue.  Block for 10 ticks if a
//        // message is not immediately available.
//        if( xQueueReceive( G8I2CQueue, &( voltage ), ( portTickType ) 10 ) )
//        {
//			
//			
//			
//			
//        }
//    }
//		 
//		
//
//		if( GraphQueue != 0 )
//    		{
//        // Send an unsigned long.  Wait for 10 ticks for space to become 
//        // available if necessary.
//		struct I2cPacket v;
//		uint8_t *ptr = (uint8_t *) buff;
//		
//		v.value = (*ptr);
//		struct I2cPacket * msg = &v;
//	//	int * msg = & temp;
//				 
//        if( xQueueSend( GraphQueue, ( void * ) &msg, ( portTickType ) 10 ) != pdPASS )
//        {
//            // Failed to post the message, even after 10 ticks.
//	        }
//			}
//
//			if (vtI2CEnQ(&devPtr,msgType,SlaveAddress,txLen,buff,0) == pdTRUE) {
//		//VT_HANDLE_FATAL_ERROR(0);
//		state=7;
//			}
//  		xLastWakeTime = xTaskGetTickCount();
//		vTaskDelayUntil( &xLastWakeTime, xFrequency );
//		if (vtI2CEnQ(&devPtr,msgType,SlaveAddress,txLen,buff,0) == pdTRUE) {
//		//VT_HANDLE_FATAL_ERROR(0);
//		state=7;
//			}
//			xLastWakeTime = xTaskGetTickCount();
//		vTaskDelayUntil( &xLastWakeTime, xFrequency );
//
//	   	// Wait for a message from an I2C operation
////		if (vtI2CDeQ(devPtr,vtI2CMLen,buff,&rxLen,&msgType,status) != pdTRUE) {
////			VT_HANDLE_FATAL_ERROR(0);
////		}
//
//
//		//volts = getValue(&msgBuffer);
////		volts = 23;
//
////
////  		xLastWakeTime = xTaskGetTickCount();
////		vTaskDelayUntil( &xLastWakeTime, xFrequency );
////		if( GraphQueue != 0 )
////    		{
////        // Send an unsigned long.  Wait for 10 ticks for space to become 
////        // available if necessary.
////		struct I2cPacket v;
////		v.value = state;
////		struct I2cPacket * msg = &v;
////	//	int * msg = & temp;
////				 
////        if( xQueueSend( GraphQueue, ( void * ) &msg, ( portTickType ) 10 ) != pdPASS )
////        {
////            // Failed to post the message, even after 10 ticks.
////			unsigned char* X_label = "failed";
////	 		GLCD_DisplayString(28,39,0.3,X_label);
////	        }
////			}
//
//			//
//	 
//
//		 	
//			
//			//vTaskSuspend(NULL);
//
//		
//		}
//		// We will never get here
//	
//}
//
//
//void SendVoltValueMsg(uint8_t value ){
//		if( GraphQueue != 0 )
//		{
//	struct I2cPacket v;
//	char buff[2];
//	memcpy(buff,(char *)&value,sizeof(value));
//	v.value = (int) buff;
//	
//	struct I2cPacket * msg = &v;			 
//    if( xQueueSend( GraphQueue, ( void * ) &msg, ( portTickType ) 10 ) != pdPASS )
//    {
//        // Failed to post the message, even after 10 ticks.
//        }
//		
//
//	 }
//
//
//
//}
//
//void InitG8I2CTask(){
// static unsigned char ucParameterToPass;
//	xTaskHandle G8I2CTaskHandle;
//
//	
//  /* Create the task, storing the handle.  Note that the passed parameter 
//  ucParameterToPass must exist for the lifetime of the task, so in this 
//  case is declared static.  If it was just an an automatic stack variable 
//  it might no longer exist, or at least have been corrupted, by the time
//  the new task attempts to access it. */
//  xTaskCreate( G8I2CTaskCode, ( signed char * ) "G8 I2C Task",10*configMINIMAL_STACK_SIZE, NULL, tskIDLE_PRIORITY
//  , &G8I2CTaskHandle );
//  G8I2CQueue = xQueueCreate( 10, sizeof(vtI2CMLen)  );
//
//}
//
////
////uint8_t getValue(vtVoltageMsg * Buffer)
////{
////	uint8_t *ptr = (uint8_t *) Buffer->buf;
////	return(*ptr);
////}